/**
 * Created by CK on 2017/1/18.
 */
$(document).ready(function(){
    var schoolId = xhTool.getQuery('iSchoolId');
    var domRequest  = $('#tabResRequest');
    var domList     = $('#tabResList');
    var domLog      = $('#tabNginxLog');
    var domDevList  = $('#tabDevList');
    var funState;
    getBoxState();
    $('#bt_auto_refresh', window.top.document).unbind().click(function(){
        if($(this).hasClass('active')){
            $(this).removeClass('active');
            clearInterval(funState);
        }
        else{
            $(this).addClass('active');
            funState = setInterval(function () {
                getBoxState();
            }, 1000 * 10);
        }
    });
    function getBoxState()
    {
        if(schoolId){
            $.post(baseUrl + 'Server/getBoxStateBySchool', {iSchoolId: schoolId}, function(data){
                domRequest.html(data.resRequest);
                domList.html(data.resList);
                domLog.html(data.nginxLog);
                domDevList.html(data.devList);
            }, 'json');
        }
        else{
            window.top.xhTop.showMessage({title: '缺少学校ID！', type: 'error'});
        }
    }
});
